﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PSE.Framework.Versions.Common.Configuration
{
    public class VersionServer
    {
        public string ServerName { get; set; }
        public int Port { get; set; }

        public override bool Equals(object obj)
        {
            if (obj is VersionServer)
            {
                VersionServer versionServer = (VersionServer)obj;
                return Equals(versionServer);
            }
            else
            {
                throw new InvalidCastException();
            }
        }

        public bool Equals(VersionServer obj)
        {
            if (obj == null) return false;
            return (this.ServerName.Equals(obj.ServerName, StringComparison.InvariantCultureIgnoreCase)) && (this.Port == obj.Port);
        }

        public override string ToString()
        {
            return string.Format("{0}:{1}", this.ServerName, this.Port);
        }

        public override int GetHashCode()
        {
            return this.ServerName.GetHashCode();
        }
    }
}